<?php
namespace app\common\model;




class RoomHistory extends Base
{
    public function getHistoryList($user_id){

        $join = [
            ['room rm','rm.room_id = ph.room_id','left'],
        ];
        $file = 'rm.room_name,rm.room_id,rm.is_lock,rm.password,rm.img,ph.update_time';
        $where = array('ph.user_id'=>$user_id,'rm.status'=>1);
        $rows =  $this->alias('ph')->field($file)->join($join)->where($where)->order('update_time desc')->paginate()->each(function ($item)use($user_id){
            $item['hot'] = hotValue($item['room_id']);
            $item['power'] = getPowerCode($user_id,$item['room_id']);
            $item['formatTime'] = formatTime($item['update_time']);
        });
        return ['thisPage'=>$rows->currentPage(),'hasNext'=>$rows->hasMore(),'data'=>$rows->items()];
    }


}